#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
using namespace std;
void handler(int sign)
{
    cout << "进程捕捉到了一个信号，信号编号是：" << sign << endl;
}

int main()
{
    signal(2, handler);
    while (true)
    {
        std::cout << "进程ID：" << getpid() << std::endl;
        sleep(2);
    }
    return 0;
}